Skip to content

Conversation

@CoMPaTech
Copy link
Owner

@CoMPaTech CoMPaTech commented Oct 1, 2025

Summary by CodeRabbit

  • New Features

    • Added support for an alternate login URL for v6 devices with automatic fallback when the default endpoint isn’t found.
    • Introduced a dedicated error type for unavailable device URLs to improve error handling.
  • Bug Fixes

    • Clearer error reporting when a device’s login URL is unavailable; fallback attempts are surfaced.
  • Documentation

    • Updated changelog with a new 0.5.4 release entry.
  • Chores

    • Bumped version to 0.5.4.

@CoMPaTech CoMPaTech added the enhancement New feature or request label Oct 1, 2025
@coderabbitai
Copy link

coderabbitai bot commented Oct 1, 2025

Walkthrough

Replaces the single login URL with a map of login URLs and adds fallback logic to try a v6 alternate; surfaces 404 responses as a new AirOSUrlNotFoundError; updates auth storage/connected logic to consider multiple login URLs; bumps package to 0.5.4 and adds CHANGELOG entry dated 2025-10-01.

Changes

Cohort / File(s) Summary
Auth / Login flow
airos/base.py
Replaces single hard-coded login URL with a map of login URLs (default, v6_alternative); treats 404 responses as URL-not-found and raises AirOSUrlNotFoundError; login tries default then falls back to v6_alternative; successful login stores auth keyed by the used login URL and marks client as connected; combined errors surfaced if both attempts fail.
Exceptions
airos/exceptions.py
Adds public exception AirOSUrlNotFoundError (subclass of AirOSException) for unavailable device URLs.
Release metadata / Changelog
pyproject.toml, CHANGELOG.md
Bumps package version to 0.5.4; adds 0.5.4 changelog entry dated 2025-10-01 describing the alternate/v6 login URL addition.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant C as Client
  participant A as AirOS Client
  participant D as Device

  Note over A: Login: try default → fallback to v6_alternative on 404

  C->>A: login(credentials)
  rect rgba(200,230,200,0.12)
    A->>D: POST /api/auth/login (default)
    alt 200 OK
      D-->>A: 200 + session/token
      A-->>C: success (store auth for default URL)
    else 404 Not Found
      D-->>A: 404
      A->>D: POST /api/auth/login (v6_alternative)
      alt 200 OK
        D-->>A: 200 + session/token
        A-->>C: success (store auth for v6_alternative)
      else error
        D-->>A: error (4xx/5xx)
        A-->>C: raise AirOSUrlNotFoundError or underlying error
      end
    else other error
      D-->>A: error
      A-->>C: raise corresponding exception
    end
  end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

  • Further refactoring #70 — Refactors/centralizes request and login flow; likely overlaps with the login fallback and URL/404 handling changes in this PR.

Poem

I hop between two paths today,
Default first, then v6 I survey.
A 404 may block my way,
I try the other, come what may.
Version bumped — a joyful hop 🐇✨

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title succinctly and accurately describes the core change of the pull request, namely the addition of the login.cgi endpoint to support v6 devices. It is concise, uses clear technical terminology, and provides enough context for maintainers to understand its purpose at a glance.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch v6urls

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5ad5f8b and d86d348.

📒 Files selected for processing (1)
  • pyproject.toml (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Process test coverage
🔇 Additional comments (1)
pyproject.toml (1)

7-7: Version bump looks consistent.

0.5.4 lines up with the new CHANGELOG entry and the wider v6 login support described in this PR. LGTM.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
airos/base.py (1)

310-317: Content-Type/body mismatch in update_check(force).

You send JSON while forcing application/x-www-form-urlencoded. Use JSON consistently (matches the non-force branch), or switch to form_data. Suggest JSON for both.

         if force:
             return await self._request_json(
                 "POST",
                 self._update_check_url,
                 json_data={"force": True},
                 authenticated=True,
-                ct_form=True,
+                ct_json=True,
             )
🧹 Nitpick comments (2)
airos/exceptions.py (1)

44-46: Docstring capitalization.

Use “URL” for consistency with other docstrings.

-class AirOSUrlNotFoundError(AirOSException):
-    """Raised when url not available for device."""
+class AirOSUrlNotFoundError(AirOSException):
+    """Raised when URL not available for device."""
airos/base.py (1)

74-79: Avoid future URL-membership slips with a helper.

Centralize the check to prevent repeats of the dict-membership bug.

         # Mostly 8.x API endpoints, login/status are the same in 6.x
         self._login_urls = {
             "default": f"{self.base_url}/api/auth",
             "v6_alternative": f"{self.base_url}/login.cgi",
         }
+        self._login_url_set = frozenset(self._login_urls.values())
+
+    def _is_login_url(self, url: str) -> bool:
+        return url in self._login_url_set

Then replace url in self._login_urls.values() with self._is_login_url(url) in this file.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0eafdf1 and f68f572.

📒 Files selected for processing (4)
  • CHANGELOG.md (1 hunks)
  • airos/base.py (6 hunks)
  • airos/exceptions.py (1 hunks)
  • pyproject.toml (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
airos/base.py (1)
airos/exceptions.py (2)
  • AirOSUrlNotFoundError (44-45)
  • AirOSConnectionSetupError (8-9)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Run mypy
🔇 Additional comments (1)
pyproject.toml (1)

7-7: Align release version with CHANGELOG entry.

CHANGLELOG lists 0.5.4 while pyproject is 0.5.4a1. Either change CHANGELOG to 0.5.4a1 or bump this to 0.5.4 before publishing to avoid confusion for users and tooling.

@codecov
Copy link

codecov bot commented Oct 1, 2025

Codecov Report

❌ Patch coverage is 50.00000% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 91.27%. Comparing base (0eafdf1) to head (d86d348).
⚠️ Report is 4 commits behind head on main.

Files with missing lines Patch % Lines
airos/base.py 45.45% 6 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #100      +/-   ##
==========================================
- Coverage   91.85%   91.27%   -0.59%     
==========================================
  Files           7        7              
  Lines         909      917       +8     
==========================================
+ Hits          835      837       +2     
- Misses         74       80       +6     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f68f572 and 5ad5f8b.

📒 Files selected for processing (2)
  • airos/base.py (6 hunks)
  • pyproject.toml (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • airos/base.py

@sonarqubecloud
Copy link

sonarqubecloud bot commented Oct 1, 2025

@CoMPaTech CoMPaTech merged commit 753dc57 into main Oct 1, 2025
12 of 14 checks passed
@CoMPaTech CoMPaTech deleted the v6urls branch October 1, 2025 11:25
@coderabbitai coderabbitai bot mentioned this pull request Oct 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants